package com.yuan.fruitweb.dao;

/**
 * @author YuanYuemeng
 * @date 2020/11/23
 */

import com.yuan.fruitweb.model.Fruit;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 对水果进行操作------------业务层发的通知
 */
public interface FruitDao {

    @Insert("insert into tb_fruit values(default,#{name},#{count},#{price},#{remark})")
    boolean save(Fruit fruit);

    @Delete("delete from tb_fruit where id=#{id}")
    void del(int id);

    @Select("select * from tb_fruit where id=#{id}")
    Fruit findById(int id);

    @Update("update tb_fruit set name=#{name},price=#{price},count=#{count},remark=#{remark} where id=#{id}")
    boolean update(Fruit fruit);

    @Select("select * from tb_fruit")
    List<Fruit> findAll();
}
